//
//  RenderManager.m
//  GLSprite
//
//  Created by Daniel Polak on 7/19/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "RenderManager.h"
#import "Mind.h"
#import "BaseObject.h"
#import "Vector.h"
#import "ParticleEmitter.h"

@implementation RenderManager

@synthesize m_pMind , m_pObjects, m_pEmitters;

static RenderManager* instance = nil;

+ (RenderManager *)renderManager { 
	if ( instance == nil ) { 
		instance = [[self alloc] init];
	} 
	return instance;
}

- (void)Setup {
	m_pMind = [Mind mind];
	m_pObjects = [m_pMind vObjects];
	m_pEmitters = [m_pMind vParticleEmitters];
}

- (void)Cleanup {
	
}

- (void)RenderGameObjects {
	Vector* pObjects = [m_pMind vObjects];
	int nObjectCount = [pObjects nSize];
	for (int i = 0; i < nObjectCount; ++i) {
		[(BaseObject*)[pObjects objectAtIndex:i] Render];
	}
	 
}

- (void)UpdateParticles {
	Vector* vEmitters = [m_pMind vParticleEmitters];

	for (int i = 0; i < vEmitters.nSize; ++i) {
		ParticleEmitter* pEmitter = (ParticleEmitter*)[vEmitters objectAtIndex:i];
		[pEmitter Update: [[Mind mind] DeltaTime]];
	}
}

- (void)RenderParticles {
	
}

- (void)RenderBackgrounds {
	
}

@end
